// 将数字段位转换为中文
let rankCompute = (rank)=>{
  let textRank = ''
  let ten = Math.floor(rank/10)
  let one = Math.floor(rank%10/2)
  switch (ten){
    case 1:
      textRank+='菜鸟'
      break;
    case 2:
      textRank+='业余'
      break;
    case 3:
      textRank+='职业'
      break;
    case 4:
      textRank+='大师'
      break;
    case 5:
      textRank+='棋圣'
      break;
    case 6:
      textRank+='棋仙'
      break;
    default:
      textRank='无段位'
      break;
  }
  switch (one){
    case 0:
      textRank+='零段'
      break;
    case 1:
      textRank+='一段'
      break;
    case 2:
      textRank+='二段'
      break;
    case 3:
      textRank+='三段'
      break;
    case 4:
      textRank+='四段'
      break;
    case 5:
      textRank+='五段'
      break;
    default:
      textRank='无段位'
      break;
  }
  return textRank
}

// 将字符串,分割数组
let strToArr = (str)=>{
  return str.split(',')
}

// 重置用于展示的信息格式
let resetUserInfo = (result)=>{
  result.data.nowRank = rankCompute(result.data.nowRank)
  result.data.bestRank = rankCompute(result.data.bestRank)
  result.data.area = strToArr(result.data.area)
  return result
}

export { rankCompute,strToArr,resetUserInfo }